const express = require('express');  
const cors = require('cors');  
const http = require('http');  
const { Server } = require('socket.io');  

const app = express();  
const server = http.createServer(app);  
const io = new Server(server);  

// 允许来自http://localhost:8080的请求  
app.use(cors({  
  origin: 'http://localhost:8080',  
  methods: ['GET', 'POST'],  
  credentials: true // 如果需要发送cookies，设置为true  
}));  

// Socket.IO服务器设置...  

server.listen(9090, () => {  
  console.log('Server is listening on port 9090');  
});